package com.skygrass.caesar.provider.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.skygrass.caesar.provider.entity.Book;
import com.skygrass.caesar.provider.repository.BookRepository;

@RestController
@RequestMapping("/book")
@RefreshScope
public class BookController
{
	@Autowired
	BookRepository bookRepository;

	@Value("${server.port}")
	String port;

	@Value("${testpro1}")
	private String testpro1;

	@GetMapping("/{id}")
	public Book get(@PathVariable Long id)
	{
		System.out.println("~~~~~~~~~" + port + "~~~~~~~~~~~~~~~~~");
		return bookRepository.findOne(id);
	}

	@GetMapping("/hello")
	public String helloConsumer()
	{
		return testpro1;
	}
}
